package top.chengdongqing.mishop.cart

import top.chengdongqing.mishop.entities.CartItem
import java.io.Serializable
import java.math.BigDecimal

data class CartItemDTO(
    val id: Int?,
    val productId: Int,
    val productName: String?,
    val skuId: Int,
    val skuName: String?,
    val pictureUrl: String?,
    val price: BigDecimal?,
    val quantity: Int,
    val isChecked: Boolean
) : Serializable {
    companion object {
        fun of(item: CartItem): CartItemDTO {
            return CartItemDTO(
                item.id,
                item.product.id,
                item.product.name,
                item.sku.id,
                item.sku.name,
                item.sku.pictureUrl,
                item.sku.price,
                item.quantity,
                item.isChecked
            )
        }
    }
}
